<!-- $Id: goods_list.htm 17126 2010-04-23 10:30:26Z liuhui $ -->

{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}
{include file="goods_search_trans.htm"}
<!-- 商品列表 -->
<form method="post" action="" name="listForm" onsubmit="return confirmSubmit(this)">
  <!-- start goods list -->
  <div class="list-div" id="listDiv">
{/if}
<div align="center">
{$next_sku}
</div>
<table cellpadding="3" cellspacing="1">
  <tr>
    
    <th>{$lang.image}</th>
    <th><a href="javascript:listTable.sort('goods_name'); ">{$lang.goods_name}</a>{$sort_goods_name}</th>
    <th><a href="javascript:listTable.sort('goods_sn'); ">{$lang.goods_sn}</a>{$sort_goods_sn}</th>
    <th><a href="javascript:listTable.sort('shop_price'); ">{$lang.shop_price}</a>{$sort_shop_price}</th>
    <th><a href="javascript:listTable.sort('is_on_sale'); ">{$lang.is_on_sale}</a>{$sort_is_on_sale}</th>

    <th><a href="javascript:listTable.sort('sort_order'); ">{$lang.sort_order}</a>{$sort_sort_order}</th>
   
	 <th>语种</th>
	 <th>翻译</th>
	
   
  <tr>
  {foreach from=$goods_list item=goods key=key}
  <tr>
    
    <td class="first-cell"  align="center">
		<img src="../{$goods.thumbnail}" width="100" height="80" align="center">
	
	</td>
    <td class="first-cell" >{$goods.name|escape:html}</td>
    <td>{$goods.sku}</td>
    <td align="right">{$goods.price}

    </td>
    <td align="center"><img src="images/{if $goods.status}yes{else}no{/if}.gif"  /></td>
  
    <td align="center"><span onclick="listTable.edit(this, 'edit_sort_order', {$goods.sku})">{$goods.sort_order}</span></td>
  	<td align="center">{$lang_set[$goods.store]}</td>
	
	 <td align="center">
			<span id="trans_status_{$key}">
				{if $goods.is_trans}<img src="images/yes.gif" />{else}<a href="javascript:;" onclick="single_trans('{$key}');return false;"><img src="images/no.gif" border="0" /></a>{/if}
				
			</span>	&nbsp;
			<script  id="js_{$key}" type="text/javascript"  translink="goods_trans.php?act=batch&type=auto_translate&sku={$goods.sku}&run={$key}&store={$goods.store}" ></script>
			<script language="javascript" type="text/javascript">var js_id_{$key} = "{$goods.sku}";</script>
	
	</td>
	
	
  
	
  </tr>
  {foreachelse}
  <tr><td class="no-records" colspan="11">{$lang.no_records}</td></tr>
  {/foreach}
</table>
<!-- end goods list -->

<!-- 分页 -->
<table id="page-table" cellspacing="0">
  <tr>
    <td align="right" nowrap="true">
    {include file="page.htm"}
    </td>
  </tr>
</table>

{if $full_page}
</div>

<div align="center">
  <input type="hidden" name="act" value="batch" />
  <select name="target_cat" style="display:none">
    <option value="0">{$lang.select_please}</option>{$cat_list}
  </select>
	{if $suppliers_list > 0}
  <!--二级主菜单：转移供货商-->
  <select name="suppliers_id" style="display:none">
    <option value="-1">{$lang.select_please}</option>
    <option value="0">{$lang.lab_to_shopex}</option>
    {foreach name=sln from=$suppliers_list item=sl}
      <option value="{$sl.suppliers_id}">{$sl.suppliers_name}</option>
    {/foreach}
  </select>
  <!--end!-->
	{/if}  
  {if $code neq 'real_goods'}
  <input type="hidden" name="extension_code" value="{$code}" />
  {/if}
  
  <input type="button" name="auto_translate" value="开始翻译" onclick="run=0;next_trans();" style="display:;"  />
   &nbsp;&nbsp;  
  <input type="button" name="Deploy Ok" value="清除不可翻译数据"  onclick="if(confirm('清除不可翻译数据')) location.href='goods_trans.php?act=del_trans_failed';"   />
  
  &nbsp;&nbsp;  
  <input type="button" name="Deploy Ok" value="清空"  onclick="if(confirm('确定清空数据')) location.href='goods_trans.php?act=deploy_empty';"   />

</div>
</form>

<script type="text/javascript">
  {literal}
	var run=0;	
	function next_trans(){		
		var ps = jQuery('#trans_status_'+run).position();
		document.body.scrollTop = parseInt(ps.top)-180;		
		var obj = document.getElementById('js_'+run);				
		if(obj!=undefined) {	
			document.getElementById('trans_status_'+run).innerHTML='<img src="images/loader.gif" />';		
			obj.src  = obj.getAttribute('translink')+'&rnd='+Math.random();		
					
		}	
				
		run++;
		
	}
	

	function resetrun(){
		run = 0;
		clearTimeout(setTimeout(function(){next_trans();},4000)-1);		
	}
	
	
	function single_trans(run_key){
		try{
			
			document.getElementById('trans_status_'+run_key).innerHTML='<img src="images/loader.gif" />';		
			var obj = document.getElementById('js_'+run_key);	
			var url  = obj.getAttribute('translink').replace('type=auto_translate','type=single_translate');
			obj.src = url+'&rnd='+Math.random();					
		}catch(e){
			alert(e.description);
		}		
		
	}
 {/literal}
	

</script>

<script type="text/javascript">
  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}

  {literal}
  onload = function()
  {
    startCheckOrder(); // 开始检查订单
    document.forms['listForm'].reset();
  }

  /**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'trash')
      {
          return confirm(batch_trash_confirm);
      }
      else if (frm.elements['type'].value == 'not_on_sale')
      {
          return confirm(batch_no_on_sale);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext && frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }

  function changeAction()
  {
      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';
			
			{if $suppliers_list > 0}
      frm.elements['suppliers_id'].style.display = frm.elements['type'].value == 'suppliers_move_to' ? '' : 'none';
			{/if}

      if (!document.getElementById('btnSubmit').disabled &&
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }
{/literal}
</script>
{include file="pagefooter.htm"}
{/if}